<?
    /* -*- Mode: PHP5; tab-width: 4; indent-tabs-mode: nil; basic-offset: 4 -*- */

    /*********************************************************
    *            --== InArch ==--
    *
    * @author Kulikov Alexey <a.kulikov@gmail.com>
    * @version n/a
    * @since 06.06.2005
    * @copyright essentialmind.com 2005
    *
    *********************************************************/
    
    /***
    * Class passwordGenerator
    ****
    * This class helps generate random yet readable password
    ****
    * @package usefulStuff
    * @author A Kulikov <a.kulikov@gmail.com>
    * @version n/a
    * @since 06.06.2005
    * @copyright essentialmind.com 2005
    ***/
    class passwordGenerator{
        /**
         * Array of words that will be used to put together a password
         *
         * @var array
         */
        private $words = array(
                            'Hell','bOy','rasta','main','GiLL','fIre',
                            'waTer','OIL','apPle','chAn','jack','lEX',
                            'IRK','CCCP','koU','OTS','mix','k700','bmw',
                            'vw','audi','dcag','boss','gUCCi','HUgo',
                            'sAlt','pEpA','tRox','trAx','mary','Ann',
                            'LISA','DoLy','five','six','One','twO',
                            'Tres','four','even','Oche','nuOno'
                            );
                            
        /**
         * Allowable letters for the creation of a random string
         *
         * @var unknown
         */
        private $string = 'abcdefghjkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ';
        
        
        /**
         * Constructor
         *
         */
        public function __construct(){  
            //
        }
        
        
        /**
         * Actual password creator
         *
         * @param integer $words    number of words to use in the password
         * @param integer $letters  number of random letter to use in the password
         * @param integer $numbers  number of integers to use in the password
         * @return string
         */
        public function getPass($words=2,$letters=2,$numbers=2){
            $password = null;
            $totalWords = count($this->words);
            
            for($i=0;$i<$words;$i++){
                $randomIndex = rand(0,$totalWords);
                $password .= $this->words[$randomIndex];
            }
            
            for($i=0;$i<$letters;$i++){
                $password .= $this->random_char();
            }
            
            for($i=0;$i<$numbers;$i++){
                $password .= rand(1,9);
            }
            
            return $password;
        }  
        
        
        /**
         * picks a charachter at random from a preset string
         *
         * @return unknown
         */
        private function random_char(){
    		$length = strlen($this->string);
    		$position = mt_rand(0, $length - 1);
    		return($this->string[$position]);
      	} 
    }
?>